<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
<!--		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.13/lib/theme-chalk/index.min.css" />-->
		<script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist/jquery.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.min.js"></script>
<!--		<script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.13/lib/index.min.js"></script>-->
		<link rel="stylesheet" th:href="@{/static/bootstrap.min.css}" />
	</head>
	<body>
	<div class="container-fluid" id="app" style="margin-top: 120px;margin-bottom: 100px">
		<div class="container">
			<div class="row">
				<a href="/register.html">还没有账号?点我立即去注册</a>
				<div class="col-md-4 col-md-offset-4" style="border: 1px solid #cccccc ;border-radius: 5px;margin-top: 10px">
					<form>
						<div class="form-group">
							<label for="exampleInputEmail1">username</label>
							<input type="text" v-model="loginForm.sellerName" name="username" class="form-control" id="exampleInputEmail1" placeholder="请输入用户名">
						</div>
						<div class="form-group">
							<label for="exampleInputPassword1">password</label>
							<input type="password" v-model="loginForm.sellerPassword" name="password" class="form-control" id="exampleInputPassword1" placeholder="请输入密码">
						</div>
						<div class="form-group">
							<label for="code">验证码</label>
							<input type="text" v-model="loginForm.code" name="code" class="form-control" id="code" placeholder="请输入验证码">
							<a @click.prevent="refreshCode"><img src="/seller/getKaptchaImage" id="imgCode" />点击刷新</a>
						</div>
						<button type="submit" @click.prevent="toLogin" class="btn btn-success">登 录</button>
					</form>
				</div>
			</div>
		</div>
	</div>
	<script>
		new Vue({
			el: "#app"
			,
			data: {
				loginForm:{
					sellerName:"",
					sellerPassword:"",
					code:""
				}
			}
			,
			methods: {
				toLogin(){
					console.log(this.loginForm)
					$.post("/seller/login",this.loginForm,function (data) {
						console.log(data)
						if (data=="ok"){
							parent.location.href="/"
						}else{
							alert(data)
						}
					})
				}
				,
				refreshCode(){
					let imgSrc="/seller/getKaptchaImage?date="+new Date().valueOf();
					document.getElementById("imgCode").src=imgSrc;
				}
			}
			,
			created(){
			}
		});
	</script>

	</body>
</html>
